"""
新增一条商品spu数据到表member_level_sku
把商品名为 的 加一
删除名称为 的商品
"""
# 导包
import pymysql

# 定义全局变量
conn = None
cursor = None
try:
    # 创建连接
    conn = pymysql.connect(host="127.0.0.1", port=3306, user="root", password="mengyue", database="jiuchao",
                           charset="utf8")
    # 创建游标
    cursor = conn.cursor()
    # 执行insert语句
    cursor.execute(
        "INSERT INTO `jiuchao`.`member_level_sku`(`id`, `level_id`, `level`, `sku_id`, `spu_id`, `spu_name`, "
        "`sku_properties`, `discount`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, "
        "`tenant_id`) VALUES (100, 8, 3, 2430, 1116, '测试商品2号酒', '现货：50ml*50', 99, '125', "
        "'2025-10-11 10:57:07', '125', '2025-10-11 10:57:07', b'0', 1);")
    # 提交事务
    conn.commit()
    # 回滚事务
    conn.rollback()
except Exception as err:
    print("插入数据异常:", str(err))
    # 回滚事务
    conn.rollback()
finally:
    # 关闭游标
    cursor.close()
    # 关闭连接
    conn.close()
